package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.model.User;
import com.zzgele.qmzb.api.service.UserService;
import com.zzgele.qmzb.api.utils.PageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
* Created by Martin on 2017/08/04.
*/
@RestController
@RequestMapping("/anchor")
public class AnchorController {
    private final Logger logger = LoggerFactory.getLogger(AnchorController.class);
    @DubboConsumer
    private UserService userService;

    @PostMapping("/order/ticket")
    public Result list(Long login_uid, Integer page, Integer page_size) {
        //主播收到的民票排行
        PageHelper.startPage(page, page_size);
        Condition condition = new Condition(User.class);
        condition.createCriteria().andCondition("user_type=1 and account_status=1 and ticket_total>0" );
        condition.setOrderByClause("ticket_total DESC");
        List<User> list = userService.findByCondition(condition);
        HashMap roomListHashMap = PageUtil.getPageInfoHashMap(new PageInfo(list));
        return ResultGenerator.genSuccessResult(roomListHashMap);
    }
}
